Skip to content

Validate string literals#222

Merged
bors[bot] merged 1 commit into
rust-lang:masterfrom
aochagavia:string-validation
Nov 10, 2018
Merged

Validate string literals#222
bors[bot] merged 1 commit into
rust-lang:masterfrom
aochagavia:string-validation

Conversation

@aochagavia

@aochagavia aochagavia commented Nov 9, 2018

Copy link
Copy Markdown
Contributor

Related: #6 (some validators are still missing), fixes #27

"PrefixExpr": (),
"RangeExpr": (),
"BinExpr": (),
"String": (),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we can avoid the name String here (bikeshed: StringLit, StringExpr etc.)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure... The token is called STRING and as far as I know the generator requires that you use the token name in CamelCase. Maybe @matklad knows?

// the newline, and all whitespace at the beginning of the next line are ignored
match self.peek() {
Some('\n') | Some('\r') => {
self.skip_whitespace();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in assuming that this will eat the sequence: "\r\n" for windows?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\n is whitespace playground link, so it should do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does

}
}

#[cfg(test)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

@kjeremy

kjeremy commented Nov 9, 2018

Copy link
Copy Markdown
Contributor

Is there any way we can void redefining String? Maybe it should be StringLiteral or something?

// the newline, and all whitespace at the beginning of the next line are ignored
match self.peek() {
Some('\n') | Some('\r') => {
self.skip_whitespace();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this eat a string of the form

"\
<all whitespace>
more text"

where there is an entirely whitespace line. See that \n is whitespace playground link.

The current behaviour appears to be that, unless I'm mistaken.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will indeed eat all the whitespace, including new lines, as does the Rust compiler. See this playground link

@aochagavia

Copy link
Copy Markdown
Contributor Author

bors r+

bors Bot added a commit that referenced this pull request Nov 10, 2018
222: Validate string literals r=aochagavia a=aochagavia

Related: #6 (some validators are still missing), fixes #27

Co-authored-by: Adolfo Ochagavía <github@adolfo.ochagavia.xyz>
@bors

bors Bot commented Nov 10, 2018

Copy link
Copy Markdown
Contributor

Build succeeded

@bors bors Bot merged commit 3b4c02c into rust-lang:master Nov 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prototype validators API

3 participants